<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            width: 100px;
            margin-top: 5px;
            list-style: none;
            border: 1px solid #000;
        }

        ul {
            width: 100px;
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <ul>
        <li><input type="checkbox" id="ckall"><span id="qq">全选</span></li>
        <li><input type="checkbox" class="ck"> 选项1</li>
        <li><input type="checkbox" class="ck"> 选项2</li>
        <li><input type="checkbox" class="ck"> 选项3</li>
        <li><input type="checkbox" class="ck"> 选项4</li>
        <li><input type="checkbox" class="ck"> 选项5</li>
        <li><input type="checkbox" class="ck"> 选项6</li>
        <li><input type="checkbox" class="ck"> 选项7</li>
    </ul>

</body>
<script>
    let ckall = document.getElementById("ckall")
    console.log(ckall);
    let qq = document.getElementById("qq")
    let ck = document.querySelectorAll(".ck")
    console.log(ck);
    ckall.onmouseup = function () {
        for (let i = 0; i < ck.length; i++) {
            if (ckall.checked == false) {
                qq.innerText = "全不选"
                ck[i].checked = true
            } else {
                qq.innerText = "全选"
                ck[i].checked = false
            }

        }
    }
</script>

</html>